//
//  PaperTypeModel.m
//  德方军考通
//
//  Created by 毕武侠 on 2016/11/9.
//  Copyright © 2016年 毕武侠. All rights reserved.
//

#import "PaperTypeModel.h"

@implementation PaperTypeModel

+ (instancetype)createQuestKindWithType:(NSUInteger)type {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = (type == 0 || type == 2) ? @"【单选题】" : @"【多选题】";
    model.color = @"MainColor";
    
    return model;
}

+ (instancetype)createQuestKindWithType:(NSUInteger)type andStr:(NSString *)str {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    NSString *typeStr = (type == 0 || type == 2) ? @"【单选题】" : @"【多选题】";

    
//    0 单选   1 多选  2  问答    知博院试题类型
    if (type == 0) {
        typeStr = @"【单选题】";
    }else if (type == 1){
        typeStr = @"【多选题】";
    }else if (type ==2){
        typeStr = @"【问答题】";
    }
    model.content = [NSString stringWithFormat:@"%@%@", str, typeStr];
    model.color = @"MainColor";
    
    //暂时注释
//    model.content = [typeStr stringByReplacingOccurrencesOfString:@" " withString:@""];

    
    return model;
}

+ (instancetype)createWendaAnswer{
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = @"【答案】\n";
    model.color = @"MainColor";
    
    return model;
}

+ (instancetype)createQuestAnaly {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = @"【解析】\n";
    model.color = @"MainColor";
    
    return model;
}

+ (instancetype)createQuestTest {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = @"【论述题】";
    model.color = @"MainColor";
    
    return model;
}

+ (instancetype)createQuestTestAnswer {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = @"【参考答案】";
    model.color = @"MainColor";
    
    return model;
}

+ (instancetype)createQuestTestMaterial {
    PaperTypeModel *model = [[PaperTypeModel alloc] init];
    model.type = @"text";
    model.content = @"【分析材料】";
    model.color = @"MainColor";
    
    return model;
}

- (void)mj_keyValuesDidFinishConvertingToObject {
    CGFloat minsize = 15;
//    CGFloat minsize = 40;
    CGFloat width = self.width ? : minsize;
    CGFloat height = self.height ? : minsize;
    CGFloat index = width / height;
    
    if (self.height < minsize) {
        height = minsize;
        width = height * index;
    }
    
    if (width > SCREEN_WIDTH - 16) {
        width = SCREEN_WIDTH - 16;
        height = width / index;
    }
    
    self.imageSize = CGSizeMake(width, height);
}

@end
